﻿using DeliveryService;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DeliveryWebSite
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //WEB
            //DeliveryServices.Service1SoapClient ds = new DeliveryServices.Service1SoapClient();
            //gvTest .DataSource= ds.GetBrandsByGoodsSmallCategoryName("饮料");
            //gvTest.DataBind();
            //int i = 0;

           
            var test = new List<Temp> { 
                new Temp{Id=1,Amount=2},
                new Temp{Id=2,Amount=1},
                new Temp{Id=3,Amount=3},
                new Temp{Id=4,Amount=4}
            };


          //  Response.Write(JsonConvert.SerializeObject(test));

            string str = "[{\"Id\":1,\"Amount\":2},{\"Id\":2,\"Amount\":1},{\"Id\":3,\"Amount\":3},{\"Id\":4,\"Amount\":4}]";
          //  string str = @"[{""Id"":1,""Amount"":2},{""Id"":2,""Amount"":1},{""Id"":3,""Amount"":3},{""Id"":4,""Amount"":4}]";
            var job = JArray.Parse(str);

            var foods = JArray.Parse(str).Select(x => new  
                            {
                                Food = int.Parse(x["Id"].ToString()),
                                Amount = int.Parse(x["Amount"].ToString())
                            });

            foreach (var item in job)
            {
                Response.Write(item["Id"].ToString() + "    " + item["Amount"].ToString());
            }
         

            //ServiceReferenceTest.Service1SoapClient ds = new ServiceReferenceTest.Service1SoapClient();
            //gvTest.DataSource = ds.GetAllAdvertising();
            //gvTest.DataBind();
            //int i = 0;
        } 
    }
}

public class Temp
{
    public int Id { get; set; }
    public int Amount { get; set; }
}